package com.yanliang.pojo.page;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 基本返回信息
 * @author yanliang
 * @date 2020/04/18 12:57 AM
 */
@Getter
@Setter
@ToString
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;

    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> Result<T> success() {
        return new Result<>(0, "success");
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(0, "success" , data);
    }

    public static <T> Result<T> fail(String msg) {
        return new Result<>(-1, msg);
    }
}
